#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<limits>

using namespace std;

const int INF = numeric_limits<int>::max();

vector< vector<int> > c;
vector< vector<char> > p;


int recursive_top_down(const string& a, const string& b, unsigned i, unsigned j) {
   if(c[i][j] < INF) {
      return c[i][j];
   }
   
   if(0 == i) {
      return j;
   }
   
   if(0 == j) {
      return i;
   }

   if(a[j - 1] == b[i - 1]) {
      p[i][j] = 'n';
      return (c[i][j] = recursive_top_down(a, b, i - 1, j - 1));
   }
   
   int x, y, z;   
   x = recursive_top_down(a, b, i, j - 1);
   y = recursive_top_down(a, b, i - 1, j);
   z = recursive_top_down(a, b, i - 1, j - 1);

   c[i][j] = min(x, min(y, z));

   if(c[i][j] == x){ // eliminacion
      p[i][j] = 'd';
   } else if(c[i][j] == y){ // insercion
      p[i][j] = 'i';       
   } else { // reemplazo
      p[i][j] = 'r';                        
   }

   return ++c[i][j];
}

int top_down(string& a, string& b){
   c.resize(b.size() + 1);
   p.resize(b.size() + 1);

   for(unsigned i = 0; i < c.size(); i++){
      c[i].resize(a.size()+1);
      p[i].resize(a.size()+1);
   }
   
   for(unsigned i = 0; i < c.size(); i++){
      c[i][0] = i;
      p[i][0] = 'i';
   }
   
   for(unsigned j = 0; j < c[0].size(); j++){
      c[0][j] = j;
      p[0][j] = 'd';
   }
   
   for(unsigned i = 1; i < c.size(); i++) {
      for(unsigned j = 1; j < c[0].size(); j++) {
         c[i][j] = INF;
      }
   }   
   
   p[0][0] = '*';
   
   return recursive_top_down(a, b, b.size(), a.size());
}

int bottom_up(string& a, string& b){
   c.resize(b.size() + 1);
   p.resize(b.size() + 1);
      
   for(unsigned i = 0; i < c.size(); i++){
      c[i].resize(a.size()+1);
      p[i].resize(a.size()+1);
   }
   
   for(unsigned i = 0; i < c.size(); i++){
      c[i][0] = i;
      p[i][0] = 'i';
   }
   
   for(unsigned j = 0; j < c[0].size(); j++){
      c[0][j] = j;
      p[0][j] = 'd';
   }
   
   p[0][0] = '*';
     
   for(unsigned i = 1; i < c.size(); i++){
      for(unsigned j = 1; j < c[i].size(); j++){
         if(a[j-1] == b[i-1]){
            c[i][j] = c[i-1][j-1];
            p[i][j] = 'n';
         } else {
            c[i][j] = min(c[i][j-1], min(c[i-1][j], c[i-1][j-1]));
            
            if(c[i][j-1] == c[i][j]){ // eliminacion
               p[i][j] = 'd';
            } else if(c[i][j] == c[i-1][j]){ // insercion
               p[i][j] = 'i';            
            } else { // reemplazo
               p[i][j] = 'r';                        
            }

            c[i][j]++;
         }  
      }
   }

   return c[b.size()][a.size()];
}

void print_solution(string& a, string& b){
   int i = p.size()-1;
   int j = p[0].size()-1;
   vector<int> indexes;
   vector<char> operations, characters;
      
   while(p[i][j] != '*'){
      switch(p[i][j]){
         case 'd':
            operations.push_back('d');
            indexes.push_back(j);
            characters.push_back('-');
            j--;
            break;
         case 'i':
            operations.push_back('i');
            indexes.push_back(j+1);
            characters.push_back(b[i-1]);
            i--;            
            break;
         case 'r':
            operations.push_back('r');
            indexes.push_back(j);
            characters.push_back(b[i-1]);            
            i--;
            j--;
            break;
         default:
            i--;
            j--;
      }
   }
   
   reverse(indexes.begin(), indexes.end());
   reverse(operations.begin(), operations.end());
   reverse(characters.begin(), characters.end());
   
   int ds = 0;
   
   for(unsigned i=0; i<operations.size(); i++){
      switch(operations[i]){
         case 'd':
            cout << i+1 << " Delete " << indexes[i] + ds << endl;
            ds--;
            break;
         case 'r':
            cout << i+1 << " Replace " << indexes[i] + ds << ',' << characters[i] << endl;
            break;
         case 'i':
            cout << i+1 << " Insert " << indexes[i] + ds << ',' << characters[i] << endl;
            ds++;
      }
   }
}

int main(){
   string a, b;
   bool print_endl = false; 
   
   while(getline(cin, a) && getline(cin, b)) {
      if(print_endl)
         cout << endl;
      else 
         print_endl = true;
         
      #ifdef TOPDOWN   
         cout << top_down(a, b) << endl;
      #else
         cout << bottom_up(a, b) << endl;
      #endif
      
      print_solution(a, b);
      c.clear();
      p.clear();      
   }

}

